"use strict";
! function() {

	if (!window.AICoin || !window.AICoin.chart) {
		var e = {
			"[object Boolean]": "boolean",
			"[object Number]": "number",
			"[object String]": "string",
			"[object Function]": "function",
			"[object Array]": "array",
			"[object Date]": "date",
			"[object RegExp]": "regexp",
			"[object Object]": "object",
			"[object Error]": "error"
		}, t = e.toString,
			n = e.hasOwnProperty,
			r = {};
		r.isFunction = function(e) {
			return "function" === r.type(e)
		}, r.isArray = Array.isArray, r.isWindow = function(e) {
			return null != e && e === e.window
		}, r.type = function(n) {
			return null == n ? String(n) : "object" == typeof n || "function" == typeof n ? e[t.call(n)] || "object" : typeof n
		}, r.isPlainObject = function(e) {
			if ("object" !== r.type(e) || e.nodeType || r.isWindow(e)) return !1;
			try {
				if (e.constructor && !n.call(e.constructor.prototype, "isPrototypeOf")) return !1
			} catch (t) {
				return !1
			}
			return !0
		}, r.extend = function() {
			var e, t, n, o, i, a, c = arguments[0] || {}, u = 1,
				s = arguments.length,
				d = !1;
			for ("boolean" == typeof c && (d = c, c = arguments[1] || {}, u = 2), "object" == typeof c || r.isFunction(c) || (c = {}), s === u && (c = this, --u); u < s; u++)
				if (null != (e = arguments[u]))
					for (t in e) n = c[t], o = e[t], c !== o && (d && o && (r.isPlainObject(o) || (i = r.isArray(o))) ? (i ? (i = !1, a = n && r.isArray(n) ? n : []) : a = n && r.isPlainObject(n) ? n : {}, c[t] = r.extend(d, a, o)) : void 0 !== o && (c[t] = o));
			return c
		};
		var o = {};
		! function() {
			function e(e) {
				switch (e.arrayFormat) {
					case "index":
						return function(t, r, o) {
							return null === r ? [n(t, e), "[", o, "]"].join("") : [n(t, e), "[", n(o, e), "]=", n(r, e)].join("")
						};
					case "bracket":
						return function(t, r) {
							return null === r ? n(t, e) : [n(t, e), "[]=", n(r, e)].join("")
						};
					default:
						return function(t, r) {
							return null === r ? n(t, e) : [n(t, e), "=", n(r, e)].join("")
						}
				}
			}

			function t(e) {
				var t;
				switch (e.arrayFormat) {
					case "index":
						return function(e, n, r) {
							return t = /\[(\d*)\]$/.exec(e), e = e.replace(/\[\d*\]$/, ""), t ? (void 0 === r[e] && (r[e] = {}), void(r[e][t[1]] = n)) : void(r[e] = n)
						};
					case "bracket":
						return function(e, n, r) {
							return t = /(\[\])$/.exec(e), e = e.replace(/\[\]$/, ""), t ? void 0 === r[e] ? void(r[e] = [n]) : void(r[e] = [].concat(r[e], n)) : void(r[e] = n)
						};
					default:
						return function(e, t, n) {
							return void 0 === n[e] ? void(n[e] = t) : void(n[e] = [].concat(n[e], t))
						}
				}
			}

			function n(e, t) {
				return t.encode ? t.strict ? a(e) : encodeURIComponent(e) : e
			}

			function r(e) {
				return Array.isArray(e) ? e.sort() : "object" == typeof e ? r(Object.keys(e)).sort(function(e, t) {
					return Number(e) - Number(t)
				}).map(function(t) {
					return e[t]
				}) : e
			}
			var i, a = function(e) {
					return encodeURIComponent(e).replace(/[!'()*]/g, function(e) {
						return "%" + e.charCodeAt(0).toString(16).toUpperCase()
					})
				};
			! function() {
				function e(e) {
					if (null === e || void 0 === e) throw new TypeError("Object.assign cannot be called with null or undefined");
					return Object(e)
				}

				function t() {
					try {
						if (!Object.assign) return !1;
						var e = new String("abc");
						if (e[5] = "de", "5" === Object.getOwnPropertyNames(e)[0]) return !1;
						for (var t = {}, n = 0; n < 10; n++) t["_" + String.fromCharCode(n)] = n;
						var r = Object.getOwnPropertyNames(t).map(function(e) {
							return t[e]
						});
						if ("0123456789" !== r.join("")) return !1;
						var o = {};
						return "abcdefghijklmnopqrst".split("").forEach(function(e) {
							o[e] = e
						}), "abcdefghijklmnopqrst" === Object.keys(Object.assign({}, o)).join("")
					} catch (i) {
						return !1
					}
				}
				var n = Object.getOwnPropertySymbols,
					r = Object.prototype.hasOwnProperty,
					o = Object.prototype.propertyIsEnumerable;
				i = t() ? Object.assign : function(t, i) {
					for (var a, c, u = e(t), s = 1; s < arguments.length; s++) {
						a = Object(arguments[s]);
						for (var d in a) r.call(a, d) && (u[d] = a[d]);
						if (n) {
							c = n(a);
							for (var l = 0; l < c.length; l++) o.call(a, c[l]) && (u[c[l]] = a[c[l]])
						}
					}
					return u
				}
			}();
			var c;
			! function() {
				function e(t, n) {
					try {
						return decodeURIComponent(t.join(""))
					} catch (r) {}
					if (1 === t.length) return t;
					n = n || 1;
					var o = t.slice(0, n),
						i = t.slice(n);
					return Array.prototype.concat.call([], e(o), e(i))
				}

				function t(t) {
					try {
						return decodeURIComponent(t)
					} catch (n) {
						for (var r = t.match(o), i = 1; i < r.length; i++) t = e(r, i).join(""), r = t.match(o);
						return t
					}
				}

				function n(e) {
					for (var n = {
						"%FE%FF": "��",
						"%FF%FE": "��"
					}, r = i.exec(e); r;) {
						try {
							n[r[0]] = decodeURIComponent(r[0])
						} catch (o) {
							var a = t(r[0]);
							a !== r[0] && (n[r[0]] = a)
						}
						r = i.exec(e)
					}
					n["%C2"] = "�";
					for (var c = Object.keys(n), u = 0; u < c.length; u++) {
						var s = c[u];
						e = e.replace(new RegExp(s, "g"), n[s])
					}
					return e
				}
				var r = "%[a-f0-9]{2}",
					o = new RegExp(r, "gi"),
					i = new RegExp("(" + r + ")+", "gi");
				c = function(e) {
					if ("string" != typeof e) throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof e + "`");
					try {
						return e = e.replace(/\+/g, " "), decodeURIComponent(e)
					} catch (t) {
						return n(e)
					}
				}
			}(), o.extract = function(e) {
				var t = e.indexOf("?");
				return t === -1 ? "" : e.slice(t + 1)
			}, o.parse = function(e, n) {
				n = i({
					arrayFormat: "none"
				}, n);
				var o = t(n),
					a = Object.create(null);
				return "string" != typeof e ? a : (e = e.trim().replace(/^[?#&]/, "")) ? (e.split("&").forEach(function(e) {
					var t = e.replace(/\+/g, " ").split("="),
						n = t.shift(),
						r = t.length > 0 ? t.join("=") : void 0;
					r = void 0 === r ? null : c(r), o(c(n), r, a)
				}), Object.keys(a).sort().reduce(function(e, t) {
					var n = a[t];
					return Boolean(n) && "object" == typeof n && !Array.isArray(n) ? e[t] = r(n) : e[t] = n, e
				}, Object.create(null))) : a
			}, o.stringify = function(t, r) {
				var o = {
					encode: !0,
					strict: !0,
					arrayFormat: "none"
				};
				r = i(o, r), r.sort === !1 && (r.sort = function() {});
				var a = e(r);
				return t ? Object.keys(t).sort(r.sort).map(function(e) {
					var o = t[e];
					if (void 0 === o) return "";
					if (null === o) return n(e, r);
					if (Array.isArray(o)) {
						var i = [];
						return o.slice().forEach(function(t) {
							void 0 !== t && i.push(a(e, t, i.length))
						}), i.join("&")
					}
					return n(e, r) + "=" + n(o, r)
				}).filter(function(e) {
					return e.length > 0
				}).join("&") : ""
			}, o.parseUrl = function(e, t) {
				return {
					url: e.split("?")[0] || "",
					query: this.parse(this.extract(e), t)
				}
			}
		}();
		var i = {
			host: "https://widget.aicoin.net.cn",
			$: function(e) {
				return document.getElementById(e)
			},
			uid: function() {
				return "aicoin_" + (1048576 * (1 + Math.random()) | 0).toString(16).substring(1)
			},
			onready: function(e) {
				window.addEventListener ? window.addEventListener("DOMContentLoaded", e, !1) : window.attachEvent("onload", e)
			},
			bindEvent: function(e, t, n) {
				e.addEventListener ? e.addEventListener(t, n, !1) : e.attachEvent && e.attachEvent("on" + t, n)
			},
			unbindEvent: function(e, t, n) {
				e.removeEventListener ? e.removeEventListener(t, n, !1) : e.detachEvent && e.detachEvent("on" + t, n)
			},
			clone: function(e) {
				if (null == e || "object" != typeof e) return e;
				var t = e.constructor();
				for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
				return t
			},
			isArray: function(e) {
				return "[object Array]" === Object.prototype.toString.call(e)
			},
			urlBuilderFunction: function(e) {
				for (var t = "", n = "", r = "", o = "", i = "", a = "", c = "", u = 0; u < e.length; u++)
					if (e[u]) switch (e[u].name) {
						case "website":
							t = e[u].value;
							break;
						case "utm_source":
							n = encodeURIComponent(e[u].value);
							break;
						case "utm_medium":
							r = encodeURIComponent(e[u].value);
							break;
						case "utm_term":
							o = encodeURIComponent(e[u].value);
							break;
						case "utm_content":
							i = encodeURIComponent(e[u].value);
							break;
						case "utm_campaign":
							a = encodeURIComponent(e[u].value)
					}
					return t.indexOf("#") !== -1 && (c = t.substring(t.indexOf("#")), t = t.substring(0, t.indexOf("#"))), t.indexOf("/", 9) === -1 && t.indexOf("?") === -1 && (t += "/"), t += t.indexOf("?") === -1 ? "?" : "&", t += "utm_source=" + n + "&utm_medium=" + r, "" != o && (t += "&utm_term=" + o), "" != i && (t += "&utm_content=" + i), t += "&utm_campaign=" + a, c && (t += c), t
			},
			chart: function(e) {
				this.id = i.uid();
				var t = e.symbol || "OKEXBTCQUARTERUSD";
				this.options = {
					symbol: t,
					container: e.container,
					hide_logo: e.hide_logo,
					default_step: e.default_step,
					dex: e.dex,
					lang: e.lang,
					shown_area: e.shown_area,
					disable_theme_change: e.disable_theme_change,
					disable_tool_change: e.disable_tool_change,
					hide_market_name: e.hide_market_name,
					hide_setting_button: e.hide_setting_button,
					hide_top_timeline: e.hide_top_timeline,
					hide_indicator_button: e.hide_indicator_button,
					hide_bottom_buttons: e.hide_bottom_buttons,
					default_theme: e.default_theme,
					default_open_tools: e.default_open_tools,
					top_bar_buttons: e.top_bar_buttons,
					default_settings: e.default_settings,
					default_indicators: e.default_indicators
				}, this._ready_handlers = [], this.create()
			},
			markets: function(e) {
				this.id = i.uid();
				var t = e.symbols || "OKEXBTCQUARTERUSD";
				Array.isArray(t) || (t = ["" + t]), this.options = {
					symbols: t,
					container: e.container,
					columns: e.columns,
					lang: e.lang,
					style: e.style
				}, this._ready_handlers = [], this.create()
			}
		};
		i.chart.prototype = {
			create: function() {
				var e, t = this.render(),
					n = this;
				a(t, this.options.container), e = i.$(this.id), i.bindEvent(e, "load", function() {
					n._ready = !0
				})
			},
			ready: function(e) {
				this._ready ? e.call(this) : this._ready_handlers.push(e)
			},
			render: function() {
				var e = this.generateUrl();
				//return '<iframe id="' + this.id + '" src="' + e + '" frameborder="0" allowTransparency="true" scrolling="no" allowfullscreen style="width: 100%; height: 100%;"></iframe>'
				return '<iframe id="' + 'aicoin_0e89f' + '" src="' + e + '" frameborder="0" allowTransparency="true" scrolling="no" allowfullscreen style="width: 100%; height: 100%;"></iframe>'
			},
			generateUrl: function(e) {
				function t(t, n, r) {
					return r = r || t, e[t] ? "&" + r + "=" + n : ""
				}

				function n(t, n, r) {
					var o = "",
						i = "";
					if (e[t]) {
						try {
							i = JSON.stringify(n)
						} catch (a) {}
						o = "&" + t + "=" + encodeURIComponent(i)
					} else o = void 0 !== r ? "&" + t + "=" + encodeURIComponent(JSON.stringify(r)) : "";
					return o
				}
				e = e || this.options;
				var r = "/chart/",
					o = i.host,
					a = i.urlBuilderFunction([{
						name: "website",
						value: o + r + "?symbol=" + encodeURIComponent(e.symbol) + t("default_step", e.default_step) + t("default_theme", e.default_theme) + t("disable_theme_change", e.disable_theme_change) + t("default_open_tools", e.default_open_tools) + t("disable_tool_change", e.disable_tool_change) + t("hide_logo", e.hide_logo) + t("hide_market_name", e.hide_market_name) + t("hide_bottom_buttons", e.hide_bottom_buttons) + t("dex", e.dex) + t("lang", e.lang) + t("hide_indicator_button", e.hide_indicator_button) + n("default_indicators", e.default_indicators) + t("hide_setting_button", e.hide_setting_button) + n("default_settings", e.default_settings) + t("hide_top_timeline", e.hide_top_timeline) + n("shown_area", e.shown_area) + n("top_bar_buttons", e.top_bar_buttons)
					}, {
						name: "utm_source",
						value: window.location.hostname
					}, {
						name: "utm_medium",
						value: window.location.host + window.location.pathname
					}, {
						name: "utm_campaign",
						value: "widget/chart"
					}]);
				return a
			},
			remove: function() {
				var e = i.$(this.id);
				e.parentNode.removeChild(e)
			},
			reload: function() {
				var e = i.$(this.id),
					t = e.parentNode;
				t.removeChild(e), t.innerHTML = this.render()
			}
		}, i.markets.prototype = {
			create: function() {
				var e, t = this.render(),
					n = this;
				a(t, this.options.container), e = i.$(this.id), i.bindEvent(e, "load", function() {
					n._ready = !0
				})
			},
			ready: function(e) {
				this._ready ? e.call(this) : this._ready_handlers.push(e)
			},
			render: function() {
				var e = this.generateUrl();
				return '<iframe id="' + this.id + '" src="' + e + '" frameborder="0" allowTransparency="true" scrolling="no" allowfullscreen style="width: 100%; height: 100%;"></iframe>'
			},
			generateUrl: function(e) {
				function t(t, n, r) {
					return r = r || t, e[t] ? "&" + r + "=" + n : ""
				}
				e = e || this.options;
				var n = "/amp/widgets/markets",
					r = i.host,
					a = i.urlBuilderFunction([{
						name: "website",
						value: r + n + "?" + o.stringify({
							symbols: e.symbols
						}, {
							arrayFormat: "bracket"
						}) + (Array.isArray(e.columns) ? "&" + o.stringify({
							columns: e.columns
						}, {
							arrayFormat: "bracket"
						}) : "") + t("lang", e.lang) + t("style", e.style)
					}, {
						name: "utm_source",
						value: window.location.hostname
					}, {
						name: "utm_medium",
						value: window.location.host + window.location.pathname
					}, {
						name: "utm_campaign",
						value: "widget/markets"
					}]);
				return a
			},
			remove: function() {
				var e = i.$(this.id);
				e.parentNode.removeChild(e)
			},
			reload: function() {
				var e = i.$(this.id),
					t = e.parentNode;
				t.removeChild(e), t.innerHTML = this.render()
			}
		}, i.getUrlParams = function() {
			for (var e = /\+/g, t = /([^&=]+)=?([^&]*)/g, n = window.location.search.substring(1), r = t.exec(n), o = function(t) {
					return decodeURIComponent(t.replace(e, " "))
				}, i = {}; r;) i[o(r[1])] = o(r[2]), r = t.exec(n);
			return i
		}, i.createUrlParams = function(e) {
			var t = [];
			for (var n in e) e.hasOwnProperty(n) && null != e[n] && t.push(encodeURIComponent(n) + "=" + encodeURIComponent(e[n]));
			return t.join("&")
		}, i.widget = i.chart;
		var a = function(e, t) {
			var n = i.$(t);
			n ? n.innerHTML = e : document.write(e)
		};

		window.AICoin ? r.extend(window.AICoin, i) : window.AICoin = i
	}
}();